package com.imc.apm.application.common;

import cn.hutool.core.map.MapUtil;

import java.util.Map;

/**
 * @ClassName ApiRestConstant
 * @Description 当前项目中涉及的所有API接口
 * @Author Zhang Li Tao
 * @Date 2022/6/1 10:58
 * @Version 1.0
 */
public class ApiRestConstant {
    private static final Map<String, String> apiRestMap = MapUtil.newHashMap();

    /**
     * 利用静态域装载所有的
     */
    static {
        apiRestMap.put("getBasicInfo", "/tomcatInfo/getBasicInfo");
        apiRestMap.put("getThreadInfo", "/tomcatInfo/getThreadInfo");
        apiRestMap.put("getThreadPoolState", "/tomcatInfo/getThreadPoolState");
        apiRestMap.put("getJvmState", "/tomcatInfo/getJvmState");
    }

    public static String getURIByMethodName(String methodName) {
        return apiRestMap.get(methodName);
    }
}

/**
 * 获取基本信息
 * localhost:8080/tomcatInfo/getBasicInfo
 * [
 *     {
 *         "localPort": 8080,
 *         "stateName": "STARTED",
 *         "defaultHost": "localhost"
 *     }
 * ]
 *
 *
 * 获取线程池基本信息
 * localhost:8080/tomcatInfo/getThreadInfo
 * [
 *     {
 *         "minSpareThreads": "500",
 *         "acceptCount": "100",
 *         "allowMaxConnections": 1100,
 *         "connectionTimeout": "60000",
 *         "maxConnections": "1000"
 *     }
 * ]
 *
 *
 * 获取线程池当前状态信息
 * localhost:8080/tomcatInfo/getThreadPoolState
 * [
 *     {
 *         "activeCount": 1,
 *         "taskCount": 6,
 *         "queueSize": 0,
 *         "poolSize": 500,
 *         "corePoolSize": 500,
 *         "completedTaskCount": 5,
 *         "maximumPoolSize": 800
 *     }
 * ]
 *
 *
 * 获取JVM内存状态
 * localhost:8080/tomcatInfo/getJvmState
 * [
 *     {
 *         "totalMemory": 27,
 *         "freeMemory": 0,
 *         "maxMemory": 247
 *     }
 * ]
 */
